home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / Windows.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  24KB  |  660 lines

  1. /*
  2.      File:        Windows.h
  3.  
  4.      Contains:    Window Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __WINDOWS__
  19. #define __WINDOWS__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MEMORY__
  25. #include <Memory.h>
  26. #endif
  27. #ifndef __QUICKDRAW__
  28. #include <Quickdraw.h>
  29. #endif
  30. #ifndef __EVENTS__
  31. #include <Events.h>
  32. #endif
  33. #ifndef __CONTROLS__
  34. #include <Controls.h>
  35. #endif
  36. #ifndef __HIWINDOWTYPES__
  37. #include <HIWindowTypes.h>
  38. #endif
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT_SUPPORTED
  45. #pragma import on
  46. #endif
  47.  
  48. #if PRAGMA_ALIGN_SUPPORTED
  49. #pragma options align=mac68k
  50. #endif
  51.  
  52. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  53. /*
  54. _________________________________________________________________________________________________________
  55.     
  56.  * WINDOW DEFINITION TYPE
  57. _________________________________________________________________________________________________________
  58. */
  59.  
  60. enum {
  61.     kWindowDefProcType            = 'WDEF'
  62. };
  63.  
  64. /*
  65. _________________________________________________________________________________________________________
  66.     
  67.  * WINDOW DEFINITION ID'S
  68. _________________________________________________________________________________________________________
  69. */
  70.  
  71. enum {
  72.     kStandardWindowDefinition    = 0,                            /* for document windows and dialogs*/
  73.     kRoundWindowDefinition        = 1,                            /* old da-style window*/
  74.     kFloatingWindowDefinition    = 124                            /* for floating windows*/
  75. };
  76.  
  77. /*
  78. _________________________________________________________________________________________________________
  79.     
  80.  * VARIANT CODES
  81. _________________________________________________________________________________________________________
  82. */
  83.  
  84. enum {
  85.                                                                 /* for use with kStandardWindowDefinition */
  86.     kDocumentWindowVariantCode    = 0,
  87.     kModalDialogVariantCode        = 1,
  88.     kPlainDialogVariantCode        = 2,
  89.     kShadowDialogVariantCode    = 3,
  90.     kMovableModalDialogVariantCode = 5,
  91.     kAlertVariantCode            = 7,
  92.     kMovableAlertVariantCode    = 9,                            /* for use with kFloatingWindowDefinition */
  93.     kSideFloaterVariantCode        = 8
  94. };
  95.  
  96. /*
  97. _________________________________________________________________________________________________________
  98.     
  99.  * PROC-ID'S
  100. _________________________________________________________________________________________________________
  101. */
  102.  
  103. enum {
  104.     documentProc                = 0,
  105.     dBoxProc                    = 1,
  106.     plainDBox                    = 2,
  107.     altDBoxProc                    = 3,
  108.     noGrowDocProc                = 4,
  109.     movableDBoxProc                = 5,
  110.     zoomDocProc                    = 8,
  111.     zoomNoGrow                    = 12,
  112.     rDocProc                    = 16,                            /* floating window defproc ids */
  113.     floatProc                    = 1985,
  114.     floatGrowProc                = 1987,
  115.     floatZoomProc                = 1989,
  116.     floatZoomGrowProc            = 1991,
  117.     floatSideProc                = 1993,
  118.     floatSideGrowProc            = 1995,
  119.     floatSideZoomProc            = 1997,
  120.     floatSideZoomGrowProc        = 1999
  121. };
  122.  
  123. /*
  124. _________________________________________________________________________________________________________
  125.     
  126.  * STANDARD WINDOW KINDS
  127. _________________________________________________________________________________________________________
  128. */
  129.  
  130. enum {
  131.     dialogKind                    = 2,
  132.     userKind                    = 8,
  133.     kDialogWindowKind            = 2,
  134.     kApplicationWindowKind        = 8
  135. };
  136.  
  137. /*
  138. _________________________________________________________________________________________________________
  139.     
  140.  * FIND WINDOW RESULT CODES
  141. _________________________________________________________________________________________________________
  142. */
  143.  
  144. enum {
  145.     inDesk                        = 0,
  146.     inNoWindow                    = 0,
  147.     inMenuBar                    = 1,
  148.     inSysWindow                    = 2,
  149.     inContent                    = 3,
  150.     inDrag                        = 4,
  151.     inGrow                        = 5,
  152.     inGoAway                    = 6,
  153.     inZoomIn                    = 7,
  154.     inZoomOut                    = 8
  155. };
  156.  
  157.  
  158. enum {
  159.     wDraw                        = 0,
  160.     wHit                        = 1,
  161.     wCalcRgns                    = 2,
  162.     wNew                        = 3,
  163.     wDispose                    = 4,
  164.     wGrow                        = 5,
  165.     wDrawGIcon                    = 6
  166. };
  167.  
  168.  
  169. enum {
  170.     deskPatID                    = 16
  171. };
  172.  
  173. /*
  174. _________________________________________________________________________________________________________
  175.     
  176.  * WINDOW DEFINITION HIT TEST RESULT CODES ("WINDOW PART")
  177. _________________________________________________________________________________________________________
  178. */
  179.  
  180. enum {
  181.     wNoHit                        = 0,
  182.     wInContent                    = 1,
  183.     wInDrag                        = 2,
  184.     wInGrow                        = 3,
  185.     wInGoAway                    = 4,
  186.     wInZoomIn                    = 5,
  187.     wInZoomOut                    = 6
  188. };
  189.  
  190. /*
  191. _________________________________________________________________________________________________________
  192.     
  193.  * WINDOW COLOR PART CODES
  194. _________________________________________________________________________________________________________
  195. */
  196.  
  197. enum {
  198.     wContentColor                = 0,
  199.     wFrameColor                    = 1,
  200.     wTextColor                    = 2,
  201.     wHiliteColor                = 3,
  202.     wTitleBarColor                = 4
  203. };
  204.  
  205. /*
  206. _________________________________________________________________________________________________________
  207.  * WINDOW COLOR TABLE STRUCTURE
  208. _________________________________________________________________________________________________________
  209. */
  210. struct WinCTab {
  211.     long                             wCSeed;                        /* reserved */
  212.     short                             wCReserved;                    /* reserved */
  213.     short                             ctSize;                        /* usually 4 for windows */
  214.     ColorSpec                         ctTable[5];
  215. };
  216. typedef struct WinCTab WinCTab;
  217.  
  218. typedef WinCTab *WCTabPtr;
  219. typedef WCTabPtr *WCTabHandle;
  220. /*
  221. _________________________________________________________________________________________________________
  222.  * WINDOWRECORD
  223. _________________________________________________________________________________________________________
  224. */
  225. typedef struct WindowRecord WindowRecord;
  226. typedef WindowRecord *WindowPeek;
  227. struct WindowRecord {
  228.     GrafPort                         port;
  229.     short                             windowKind;
  230.     Boolean                         visible;
  231.     Boolean                         hilited;
  232.     Boolean                         goAwayFlag;
  233.     Boolean                         spareFlag;
  234.     RgnHandle                         strucRgn;
  235.     RgnHandle                         contRgn;
  236.     RgnHandle                         updateRgn;
  237.     Handle                             windowDefProc;
  238.     Handle                             dataHandle;
  239.     StringHandle                     titleHandle;
  240.     short                             titleWidth;
  241.     ControlHandle                     controlList;
  242.     WindowPeek                         nextWindow;
  243.     PicHandle                         windowPic;
  244.     long                             refCon;
  245. };
  246.  
  247. /*
  248. _________________________________________________________________________________________________________
  249.  * CWINDOWRECORD
  250. _________________________________________________________________________________________________________
  251. */
  252. typedef struct CWindowRecord CWindowRecord;
  253. typedef CWindowRecord *CWindowPeek;
  254. struct CWindowRecord {
  255.     CGrafPort                         port;
  256.     short                             windowKind;
  257.     Boolean                         visible;
  258.     Boolean                         hilited;
  259.     Boolean                         goAwayFlag;
  260.     Boolean                         spareFlag;
  261.     RgnHandle                         strucRgn;
  262.     RgnHandle                         contRgn;
  263.     RgnHandle                         updateRgn;
  264.     Handle                             windowDefProc;
  265.     Handle                             dataHandle;
  266.     StringHandle                     titleHandle;
  267.     short                             titleWidth;
  268.     ControlHandle                     controlList;
  269.     CWindowPeek                     nextWindow;
  270.     PicHandle                         windowPic;
  271.     long                             refCon;
  272. };
  273.  
  274. /*
  275. _________________________________________________________________________________________________________
  276.  * AUXWINDHANDLE
  277. _________________________________________________________________________________________________________
  278. */
  279. typedef struct AuxWinRec AuxWinRec;
  280. typedef AuxWinRec *AuxWinPtr;
  281. typedef AuxWinPtr *AuxWinHandle;
  282. struct AuxWinRec {
  283.     AuxWinHandle                     awNext;                        /*handle to next AuxWinRec*/
  284.     WindowPtr                         awOwner;                    /*ptr to window */
  285.     CTabHandle                         awCTable;                    /*color table for this window*/
  286.     Handle                             reserved;
  287.     long                             awFlags;                    /*reserved for expansion*/
  288.     CTabHandle                         awReserved;                    /*reserved for expansion*/
  289.     long                             awRefCon;                    /*user Constant*/
  290. };
  291.  
  292. /*
  293. _________________________________________________________________________________________________________
  294.  * WSTATEHANDLE
  295. _________________________________________________________________________________________________________
  296. */
  297. struct WStateData {
  298.     Rect                             userState;                    /*user state*/
  299.     Rect                             stdState;                    /*standard state*/
  300. };
  301. typedef struct WStateData WStateData;
  302.  
  303. typedef WStateData *WStateDataPtr;
  304. typedef WStateDataPtr *WStateDataHandle;
  305. /*
  306. _________________________________________________________________________________________________________
  307.     
  308.  * API
  309. _________________________________________________________________________________________________________
  310. */
  311. extern pascal void InitWindows(void )
  312.  ONEWORDINLINE(0xA912);
  313.  
  314. extern pascal WindowPtr NewWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon)
  315.  ONEWORDINLINE(0xA913);
  316.  
  317. extern pascal WindowPtr GetNewWindow(short windowID, void *wStorage, WindowPtr behind)
  318.  ONEWORDINLINE(0xA9BD);
  319.  
  320. extern pascal WindowPtr NewCWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon)
  321.  ONEWORDINLINE(0xAA45);
  322.  
  323. extern pascal void DisposeWindow(WindowPtr theWindow)
  324.  ONEWORDINLINE(0xA914);
  325.  
  326. extern pascal void CloseWindow(WindowPtr theWindow)
  327.  ONEWORDINLINE(0xA92D);
  328.  
  329. extern pascal void InvalRect(const Rect *badRect)
  330.  ONEWORDINLINE(0xA928);
  331.  
  332. extern pascal void InvalRgn(RgnHandle badRgn)
  333.  ONEWORDINLINE(0xA927);
  334.  
  335. extern pascal void ValidRect(const Rect *goodRect)
  336.  ONEWORDINLINE(0xA92A);
  337.  
  338. extern pascal void ValidRgn(RgnHandle goodRgn)
  339.  ONEWORDINLINE(0xA929);
  340.  
  341. extern pascal Boolean CheckUpdate(EventRecord *theEvent)
  342.  ONEWORDINLINE(0xA911);
  343.  
  344. extern pascal void ClipAbove(WindowPtr window)
  345.  ONEWORDINLINE(0xA90B);
  346.  
  347. extern pascal void SaveOld(WindowPtr window)
  348.  ONEWORDINLINE(0xA90E);
  349.  
  350. extern pascal void DrawNew(WindowPtr window, Boolean update)
  351.  ONEWORDINLINE(0xA90F);
  352.  
  353. extern pascal void PaintOne(WindowPtr window, RgnHandle clobberedRgn)
  354.  ONEWORDINLINE(0xA90C);
  355.  
  356. extern pascal void PaintBehind(WindowPtr startWindow, RgnHandle clobberedRgn)
  357.  ONEWORDINLINE(0xA90D);
  358.  
  359. extern pascal void CalcVis(WindowPtr window)
  360.  ONEWORDINLINE(0xA909);
  361.  
  362. extern pascal void CalcVisBehind(WindowPtr startWindow, RgnHandle clobberedRgn)
  363.  ONEWORDINLINE(0xA90A);
  364.  
  365. extern pascal void SetWinColor(WindowPtr theWindow, WCTabHandle newColorTable)
  366.  ONEWORDINLINE(0xAA41);
  367.  
  368. extern pascal void SetDeskCPat(PixPatHandle deskPixPat)
  369.  ONEWORDINLINE(0xAA47);
  370.  
  371. extern pascal WindowPtr GetNewCWindow(short windowID, void *wStorage, WindowPtr behind)
  372.  ONEWORDINLINE(0xAA46);
  373.  
  374. extern pascal void SetWTitle(WindowPtr theWindow, ConstStr255Param title)
  375.  ONEWORDINLINE(0xA91A);
  376.  
  377. extern pascal void GetWTitle(WindowPtr theWindow, Str255 title)
  378.  ONEWORDINLINE(0xA919);
  379.  
  380. extern pascal void GetWMgrPort(GrafPtr *wPort)
  381.  ONEWORDINLINE(0xA910);
  382.  
  383. extern pascal void GetCWMgrPort(CGrafPtr *wMgrCPort)
  384.  ONEWORDINLINE(0xAA48);
  385.  
  386. extern pascal void SetWRefCon(WindowPtr theWindow, long data)
  387.  ONEWORDINLINE(0xA918);
  388.  
  389. extern pascal long GetWRefCon(WindowPtr theWindow)
  390.  ONEWORDINLINE(0xA917);
  391.  
  392. extern pascal void SelectWindow(WindowPtr theWindow)
  393.  ONEWORDINLINE(0xA91F);
  394.  
  395. extern pascal void HideWindow(WindowPtr theWindow)
  396.  ONEWORDINLINE(0xA916);
  397.  
  398. extern pascal void ShowWindow(WindowPtr theWindow)
  399.  ONEWORDINLINE(0xA915);
  400.  
  401. extern pascal void ShowHide(WindowPtr theWindow, Boolean showFlag)
  402.  ONEWORDINLINE(0xA908);
  403.  
  404. extern pascal void HiliteWindow(WindowPtr theWindow, Boolean fHilite)
  405.  ONEWORDINLINE(0xA91C);
  406.  
  407. extern pascal void BringToFront(WindowPtr theWindow)
  408.  ONEWORDINLINE(0xA920);
  409.  
  410. extern pascal void SendBehind(WindowPtr theWindow, WindowPtr behindWindow)
  411.  ONEWORDINLINE(0xA921);
  412.  
  413. extern pascal WindowPtr FrontWindow(void )
  414.  ONEWORDINLINE(0xA924);
  415.  
  416. extern pascal void DrawGrowIcon(WindowPtr theWindow)
  417.  ONEWORDINLINE(0xA904);
  418.  
  419. extern pascal void MoveWindow(WindowPtr theWindow, short hGlobal, short vGlobal, Boolean front)
  420.  ONEWORDINLINE(0xA91B);
  421.  
  422. extern pascal void SizeWindow(WindowPtr theWindow, short w, short h, Boolean fUpdate)
  423.  ONEWORDINLINE(0xA91D);
  424.  
  425. extern pascal void ZoomWindow(WindowPtr theWindow, short partCode, Boolean front)
  426.  ONEWORDINLINE(0xA83A);
  427.  
  428. extern pascal void BeginUpdate(WindowPtr theWindow)
  429.  ONEWORDINLINE(0xA922);
  430.  
  431. extern pascal void EndUpdate(WindowPtr theWindow)
  432.  ONEWORDINLINE(0xA923);
  433.  
  434. extern pascal void SetWindowPic(WindowPtr theWindow, PicHandle pic)
  435.  ONEWORDINLINE(0xA92E);
  436.  
  437. extern pascal PicHandle GetWindowPic(WindowPtr theWindow)
  438.  ONEWORDINLINE(0xA92F);
  439.  
  440. extern pascal long GrowWindow(WindowPtr theWindow, Point startPt, const Rect *bBox)
  441.  ONEWORDINLINE(0xA92B);
  442.  
  443. extern pascal short FindWindow(Point thePoint, WindowPtr *theWindow)
  444.  ONEWORDINLINE(0xA92C);
  445.  
  446. extern pascal long PinRect(const Rect *theRect, Point thePt)
  447.  ONEWORDINLINE(0xA94E);
  448.  
  449. extern pascal long DragGrayRgn(RgnHandle theRgn, Point startPt, const Rect *limitRect, const Rect *slopRect, short axis, DragGrayRgnUPP actionProc)
  450.  ONEWORDINLINE(0xA905);
  451.  
  452. extern pascal long DragTheRgn(RgnHandle theRgn, Point startPt, const Rect *limitRect, const Rect *slopRect, short axis, DragGrayRgnUPP actionProc)
  453.  ONEWORDINLINE(0xA926);
  454.  
  455. extern pascal Boolean TrackBox(WindowPtr theWindow, Point thePt, short partCode)
  456.  ONEWORDINLINE(0xA83B);
  457.  
  458. extern pascal Boolean TrackGoAway(WindowPtr theWindow, Point thePt)
  459.  ONEWORDINLINE(0xA91E);
  460.  
  461. extern pascal void DragWindow(WindowPtr theWindow, Point startPt, const Rect *boundsRect)
  462.  ONEWORDINLINE(0xA925);
  463.  
  464. extern pascal short GetWVariant(WindowPtr theWindow)
  465.  ONEWORDINLINE(0xA80A);
  466.  
  467. extern pascal Boolean GetAuxWin(WindowPtr theWindow, AuxWinHandle *awHndl)
  468.  ONEWORDINLINE(0xAA42);
  469.  
  470. extern pascal RgnHandle GetGrayRgn(void)
  471.  TWOWORDINLINE(0x2EB8, 0x09EE);
  472.  
  473. /*
  474. _________________________________________________________________________________________________________
  475.     
  476.  * PROCS
  477. _________________________________________________________________________________________________________
  478. */
  479. typedef pascal long (*WindowDefProcPtr)(short varCode, WindowPtr theWindow, short message, long param);
  480. /*
  481.         This ProcPtr uses register based parameters on the 68k and cannot
  482.         be written in or called from a high-level language without the help of
  483.         mixed mode or assembly glue.
  484.  
  485.             typedef pascal void (*DeskHookProcPtr)(Boolean mouseClick, EventRecord *theEvent);
  486.  
  487. */
  488.  
  489. #if GENERATINGCFM
  490. typedef UniversalProcPtr WindowDefUPP;
  491. typedef UniversalProcPtr DeskHookUPP;
  492. #else
  493. typedef WindowDefProcPtr WindowDefUPP;
  494. typedef Register68kProcPtr DeskHookUPP;
  495. #endif
  496.  
  497. enum {
  498.     uppWindowDefProcInfo = kPascalStackBased
  499.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  500.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  501.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(WindowPtr)))
  502.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  503.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long))),
  504.     uppDeskHookProcInfo = kRegisterBased
  505.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(Boolean)))
  506.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA0, SIZE_CODE(sizeof(EventRecord *)))
  507. };
  508.  
  509. #if GENERATINGCFM
  510. #define NewWindowDefProc(userRoutine)        \
  511.         (WindowDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppWindowDefProcInfo, GetCurrentArchitecture())
  512. #define NewDeskHookProc(userRoutine)        \
  513.         (DeskHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDeskHookProcInfo, GetCurrentArchitecture())
  514. #else
  515. #define NewWindowDefProc(userRoutine)        \
  516.         ((WindowDefUPP) (userRoutine))
  517. #define NewDeskHookProc(userRoutine)        \
  518.         ((DeskHookUPP) (userRoutine))
  519. #endif
  520.  
  521. #if GENERATINGCFM
  522. #define CallWindowDefProc(userRoutine, varCode, theWindow, message, param)        \
  523.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppWindowDefProcInfo, (varCode), (theWindow), (message), (param))
  524. #define CallDeskHookProc(userRoutine, mouseClick, theEvent)        \
  525.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDeskHookProcInfo, (mouseClick), (theEvent))
  526. #else
  527. #define CallWindowDefProc(userRoutine, varCode, theWindow, message, param)        \
  528.         (*(userRoutine))((varCode), (theWindow), (message), (param))
  529. /* (*DeskHookUPP) cannot be called from a high-level language without the Mixed Mode Manager */
  530. #endif
  531. /*
  532. _________________________________________________________________________________________________________
  533.     
  534.  * C GLUE
  535. _________________________________________________________________________________________________________
  536. */
  537. #if CGLUESUPPORTED
  538. extern void setwtitle(WindowPtr theWindow, const char *title);
  539.  
  540. extern Boolean trackgoaway(WindowPtr theWindow, Point *thePt);
  541.  
  542. extern short findwindow(Point *thePoint, WindowPtr *theWindow);
  543.  
  544. extern void getwtitle(WindowPtr theWindow, char *title);
  545.  
  546. extern long growwindow(WindowPtr theWindow, Point *startPt, const Rect *bBox);
  547.  
  548. extern WindowPtr newwindow(void *wStorage, const Rect *boundsRect, const char *title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon);
  549.  
  550. extern WindowPtr newcwindow(void *wStorage, const Rect *boundsRect, const char *title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon);
  551.  
  552. extern long pinrect(const Rect *theRect, Point *thePt);
  553.  
  554. extern Boolean trackbox(WindowPtr theWindow, Point *thePt, short partCode);
  555.  
  556. extern long draggrayrgn(RgnHandle theRgn, Point *startPt, const Rect *boundsRect, const Rect *slopRect, short axis, DragGrayRgnUPP actionProc);
  557.  
  558. extern void dragwindow(WindowPtr theWindow, Point *startPt, const Rect *boundsRect);
  559.  
  560. #endif
  561. /*
  562. _________________________________________________________________________________________________________
  563.     
  564.  * WindowRecord accessor macros
  565. _________________________________________________________________________________________________________
  566. */
  567. /*
  568. *****************************************************************************
  569. *                                                                           *
  570. * The conditional STRICT_WINDOWS has been removed from this interface file. *
  571. * The accessor macros to a WindowRecord are no longer necessary.            *
  572. *                                                                           *
  573. *****************************************************************************
  574.  
  575. Details:
  576. The original purpose of the STRICT_ conditionals and accessor macros was to
  577. help ease the transition to Copland.   Shared data structures are difficult
  578. to coordinate in a preemptive multitasking OS.  By hiding the fields in a
  579. WindowRecord and other data structures, we would begin the migration to 
  580. system data structures being completely hidden from applications. 
  581.  
  582. After many design reviews, it was finally concluded that with this sort of
  583. migration, the system could never tell when an application was no longer 
  584. peeking at a WindowRecord, and thus the data structure might never become 
  585. system owned.  Additionally, there were many other limitations in the classic
  586. toolbox that were begging to be addressed.
  587.  
  588. The final decision was to leave the traditional toolbox as a compatibility mode.
  589. The preferred toolbox API for Copland is a new SOM(tm) based architecture 
  590. (e.g. HIWindows.idl).  Windows, menu, controls, etc are each a SOM object 
  591. with methods for drawing, event handling, and customization.
  592.  
  593. */
  594. #ifdef __cplusplus
  595. inline CGrafPtr    GetWindowPort(WindowRef w)                     { return (CGrafPtr) w;                                                     }
  596. inline void        SetPortWindowPort(WindowRef aWindowRef)        {    SetPort( (GrafPtr) GetWindowPort(aWindowRef)); }
  597. inline SInt16        GetWindowKind(WindowRef w)                     { return ( *(SInt16 *)    (((UInt8 *) w) + sizeof(GrafPort)));             }
  598. inline void        SetWindowKind(WindowRef    w, SInt16 wKind)    {  *(SInt16 *)    (((UInt8 *) w) + sizeof(GrafPort)) = wKind;              }
  599. inline    Boolean        IsWindowVisible(WindowRef w)                { return *(Boolean *)    (((UInt8 *) w) + sizeof(GrafPort) + 0x2);         }
  600. inline Boolean        IsWindowHilited(WindowRef w)                { return *(Boolean *)    (((UInt8 *) w) + sizeof(GrafPort) + 0x3);        }
  601. inline Boolean        GetWindowGoAwayFlag(WindowRef w)            { return *(Boolean *)    (((UInt8 *) w) + sizeof(GrafPort) + 0x4);        }
  602. inline Boolean        GetWindowZoomFlag(WindowRef w)                { return *(Boolean *)    (((UInt8 *) w) + sizeof(GrafPort) + 0x5);        }
  603. inline void        GetWindowStructureRgn(WindowRef w, RgnHandle r)    {    CopyRgn( *(RgnHandle *)(((UInt8 *) w) + sizeof(GrafPort) + 0x6), r );    }
  604. inline void        GetWindowContentRgn(WindowRef w, RgnHandle r)    {    CopyRgn( *(RgnHandle *)(((UInt8 *) w) + sizeof(GrafPort) + 0xA), r );    }
  605. inline void        GetWindowUpdateRgn(WindowRef w, RgnHandle r)    {    CopyRgn( *(RgnHandle *)(((UInt8 *) w) + sizeof(GrafPort) + 0xE), r );    }
  606. inline SInt16        GetWindowTitleWidth(WindowRef w)                { return *(SInt16 *)(((UInt8 *) w) + sizeof(GrafPort) + 0x1E);            }
  607. inline WindowRef    GetNextWindow(WindowRef w)                        { return *(WindowRef *)    (((UInt8 *) w) + sizeof(GrafPort) + 0x24);        }
  608. inline void    GetWindowStandardState(WindowRef w, Rect *r)  \
  609. {    Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));    \
  610. if (stateRects != NULL)    *r = stateRects[1];        }
  611. inline void    SetWindowStandardState(WindowRef w, const Rect *r)    \
  612. {     Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16))); \
  613. if (stateRects != NULL)    stateRects[1] = *r;     }
  614. inline void    GetWindowUserState(WindowRef w, Rect *r)    \
  615. {     Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));    \
  616. if (stateRects != NULL)    *r = stateRects[0]; }
  617. inline void    SetWindowUserState(WindowRef w, const Rect *r)    \
  618. { Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));    \
  619. if (stateRects != NULL)    stateRects[0] = *r; }
  620. #else
  621. #define ShowHideWindow(aWindowRef)                        ShowHide(aWindowRef)
  622. #define SetPortWindowPort(aWindowRef)                    SetPort( (GrafPtr) GetWindowPort(aWindowRef) )
  623. #define    GetWindowPort(aWindowRef)                    ( (CGrafPtr) aWindowRef)
  624. #define    GetWindowKind(aWindowRef)                    ( *(SInt16 *)    (((UInt8 *) aWindowRef) + sizeof(GrafPort)))
  625. #define SetWindowKind(aWindowRef, wKind)                ( *(SInt16 *)    (((UInt8 *) aWindowRef) + sizeof(GrafPort)) = wKind )
  626. #define IsWindowVisible(aWindowRef)                    ( *(Boolean *)    (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x2))
  627. #define IsWindowHilited(aWindowRef)                    ( *(Boolean *)    (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x3))
  628. #define GetWindowGoAwayFlag(aWindowRef)                ( *(Boolean *)    (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x4))
  629. #define GetWindowZoomFlag(aWindowRef)                    ( *(Boolean *)    (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x5))
  630. #define GetWindowStructureRgn(aWindowRef, aRgnHandle)    CopyRgn( *(RgnHandle *)(((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x6), aRgnHandle )
  631. #define GetWindowContentRgn(aWindowRef, aRgnHandle)        CopyRgn( *(RgnHandle *)(((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0xA), aRgnHandle )
  632. #define GetWindowUpdateRgn(aWindowRef, aRgnHandle)        CopyRgn( *(RgnHandle *)(((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0xE), aRgnHandle )
  633. #define GetWindowTitleWidth(aWindowRef)                ( *(SInt16 *)        (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x1E))
  634. #define GetNextWindow(aWindowRef)                        ( *(WindowRef *)    (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x24))
  635. #define GetWindowStandardState(aWindowRef, aRectPtr)    do { Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x16)));    \
  636.                                                                 if (stateRects != NULL)    *aRectPtr = stateRects[1]; } while (false)
  637. #define SetWindowStandardState(aWindowRef, aRectPtr)    do { Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x16)));    \
  638.                                                                 if (stateRects != NULL)    stateRects[1] = *aRectPtr; } while (false)
  639. #define GetWindowUserState(aWindowRef, aRectPtr)        do { Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x16)));    \
  640.                                                                 if (stateRects != NULL)    *aRectPtr = stateRects[0]; } while (false)
  641. #define SetWindowUserState(aWindowRef, aRectPtr)        do { Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x16)));    \
  642.                                                                 if (stateRects != NULL)    stateRects[0] = *aRectPtr; } while (false)
  643. #endif
  644. #endif
  645.  
  646. #if PRAGMA_ALIGN_SUPPORTED
  647. #pragma options align=reset
  648. #endif
  649.  
  650. #if PRAGMA_IMPORT_SUPPORTED
  651. #pragma import off
  652. #endif
  653.  
  654. #ifdef __cplusplus
  655. }
  656. #endif
  657.  
  658. #endif /* __WINDOWS__ */
  659.  
  660.